package com.iting.aopdemo.myadvice;

import com.iting.aopdemo.MyAopAdvice;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author iting Nie
 * @version 1.1
 * @create 2021/11/16
 */
@Component
@Aspect
public class MyAopAdviceImpl implements MyAopAdvice {

    @Before("execution(* com.iting.aopdemo.*.demo(..))")
    public void demo(){
        System.out.println("Before");
    }

	@AfterReturning("execution(* com.iting.aopdemo.*.demo(..))")
	public void demo2(){
		System.out.println("AfterReturning");
	}

	@After("execution(* com.iting.aopdemo.*.demo(..))")
	public void demo3(){
		System.out.println("After");
	}

	@Around("execution(* com.iting.aopdemo.*.demo(..))")
	public Object aroundtest(ProceedingJoinPoint point){
		System.out.println("环绕前");
    	Object object = null;
		try {
			object=point.proceed();
		} catch (Throwable throwable) {
			throwable.printStackTrace();
		}
		System.out.println("环绕后");
		return object;
	}
	@AfterThrowing("execution(* com.iting.aopdemo.*.demo(..))")
	public void afterThrowing(){
		System.out.println("afterThrowing");
	}

	@Before("execution(* com.iting.aopdemo.*.demo02(..))")
	public void demo02(){
		System.out.println("Before");
	}

	@AfterReturning("execution(* com.iting.aopdemo.*.demo02(..))")
	public void demo0202(){
		System.out.println("AfterReturning");
	}

	@After("execution(* com.iting.aopdemo.*.demo02(..))")
	public void demo0203(){
		System.out.println("After");
	}
}
